<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>封闭对象的API</title>
</head>
<body>
    <script>
        // 'use strict' 
        let hd = {name:"后盾人",age:18};
        console.log(JSON.stringify(Object.getOwnPropertyDescriptors(hd),null,2));

        // 封闭对象（这个对象不能添加属性，删除属性，也不能重新定义特征）,严格模式下报错
        // Object.seal(hd);
        // console.log(JSON.stringify(Object.getOwnPropertyDescriptors(hd),null,2));
        
        // hd.size = "big";
        // delete hd.age;
        // console.log(hd);


        // Object.seal(hd);
        // 判断某个对象是否是封闭状态
        if(!Object.isSealed(hd)){
            hd.size = "big";
            delete hd.age;
        }
        console.log(hd);
    </script>
</body>
</html>